﻿<UserControl x:Class="Milestone.Presentation.Partial.Tasks.TasksView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:ts="clr-namespace:Milestone.Presentation.TemplateSelectors"
             xmlns:markup="http://schemas.topics.it/wpf/radical/windows/markup"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <Border Margin="3"
            BorderBrush="Gainsboro" BorderThickness="1,0,0,0"
            HorizontalAlignment="Stretch" VerticalAlignment="Stretch">

            <ScrollViewer HorizontalScrollBarVisibility="Disabled" 
                              VerticalScrollBarVisibility="Auto"
                              HorizontalAlignment="Stretch"
                              VerticalAlignment="Stretch">

                <ItemsControl ItemsSource="{Binding Path=Tasks}" KeyboardNavigation.IsTabStop="False">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Margin="5,0,0,3"  KeyboardNavigation.IsTabStop="False">
                                <TextBlock FontWeight="Bold" 
                                               Text="{Binding Path=Key}" 
                                               TextTrimming="CharacterEllipsis" />

                                <ItemsControl Margin="5,0,0,2" DataContext="{Binding}" ItemsSource="{Binding}" KeyboardNavigation.IsTabStop="False">
                                    <ItemsControl.ItemTemplateSelector>
                                        <ts:UserTaskTemplateSelector>
                                            <ts:UserTaskTemplateSelector.DefaultTemplate>
                                                <DataTemplate>

                                                    <StackPanel Orientation="Horizontal" KeyboardNavigation.IsTabStop="False">
                                                        <Image Source="{Binding Path=Icon}" Stretch="Uniform" Width="16" Margin="2" />

                                                        <TextBlock Margin="2,0,0,0" VerticalAlignment="Center">
                                                        <Hyperlink Command="{markup:AutoCommandBinding Path=Execute}">
                                                            <TextBlock Text="{Binding Path=DisplayName}" 
                                                                       ToolTip="{Binding Path=Description}"
                                                                       TextTrimming="CharacterEllipsis" />
                                                        </Hyperlink>
                                                    </TextBlock>
                                                    </StackPanel>

                                                </DataTemplate>
                                            </ts:UserTaskTemplateSelector.DefaultTemplate>
                                        </ts:UserTaskTemplateSelector>
                                    </ItemsControl.ItemTemplateSelector>
                                </ItemsControl>
                            </StackPanel>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </ScrollViewer>

        </Border>
    </Grid>
</UserControl>
